var winn = [];
var spacing = 150;
var hposition = 0-spacing;
var searchtext = "Enter Artist, Team or Venue";

function fclear(fld) { 	
	if (fld.value==searchtext) {
		fld.value='';
		return;
	}
}

function fpop(fld) {
	if (fld.value=='') {
		fld.value=searchtext;
		return;
	}
}

function searchTix() {

var sites = document.getElementsByName("input");

for (site in sites) {
	if (sites[site].className=='check' && sites[site].checked) {
	var sid = sites[site];
	console.log("loading site... "+sid.id);

	var opts = 'scrollbars=1,width=600,height=500,top=440';
	var siteid = sid.id;
	var rndint = getRandomArbitrary(1210,9899);
	var kwdsfld = document.getElementById('searchText');
	var kwds = kwdsfld.value;
	
	hposition = hposition+spacing;
	switch (siteid) {
		case 'ticketlodge':
			opts = opts+',left='+hposition;
			winn[6] = window.open('http://ticketlodge.com/Search?query='+kwds+'#'+rndint,'_blank',opts);
			winn[6].focus();
			break;

		case 'metroseats':
			opts = opts+',left='+hposition;
			winn[0] = window.open('http://metroseats.com/ResultsGeneral.html?stype=0&kwds='+kwds,'_blank',opts);
			winn[0].focus();
			break;

		case 'finallyitsyours':
			opts = opts+',left='+hposition;
			winn[1] = window.open('http://finallyitsyours.com/ResultsGeneral.aspx?stype=0&kwds='+kwds,'_blank',opts);
			winn[1].focus();
			break;

		case 'luckyducktickets':
			opts = opts+',left='+hposition;
			winn[2] = window.open('http://luckyducktickets.com/ResultsGeneral.html?stype=0&kwds='+kwds+'#'+rndint,'_blank',opts);
			winn[2].focus();
			break;

		case 'seatgeek':
			opts = opts+',left='+hposition;
			winn[3] = window.open('http://seatgeek.com/search?search='+kwds,'_blank',opts);
			winn[3].focus();
			break;

		case 'razorgator':
			opts = opts+',left='+hposition;
			winn[4] = window.open('http://razorgator.com/tickets/pages/search/?q='+kwds+'#'+rndint,'_blank',opts);
			winn[4].focus();
			break;

		case 'stubhub':
			opts = opts+',left='+hposition;
			winn[5] = window.open('http://stubhub.com/search/doSearch?searchStr='+kwds+'&pageNumber=1&resultsPerPage=100&searchMode=event&ae=2&start=0&rows=100&geo_exp=1','_blank',opts);
			winn[5].focus();
			break;
		
		default:
			break;
	}//switch

	}//if

}//for

return;

}

function getRandomArbitrary(min, max) {
  return Math.random() * (max - min) + min;
}




